<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>构造函数</title>
	</head>
	<body>
		<span onmousemove="liLei.intrSelf()">李雷</span>&nbsp;<span onmousemove="hanMeiMei.intrSelf()">韩梅梅</span>
		<div id="ste">123</div>
		<script type="text/javascript">
			function Student(name,age){
				this.name=name;
				this.age=age;
//				this.intrSelf=function(){
//					ste.innerHTML="I am "+this.name+", I am "+this.age;
//				};	
			}
			//函数挂在Student原型上就不用每次new的时候创建一次浪费存储空间
			Student.prototype.intrSelf=function(){
					ste.innerHTML="I am "+this.name+", I am "+this.age;
				};	
			//或者
			Student.prototype={
				constructor:Student, //修改原型对象时constructor属性会被置为Object;手动改回来（http://www.jb51.net/article/77039.htm）
				intrSelf:function(){
					ste.innerHTML="I am "+this.name+", I am "+this.age;
				}
			}
			var liLei=new Student("liLei",13);
			var hanMeiMei=new Student("hanMeiMei",14);
		</script>
	</body>
</html>
